package com.lyn.chapter3.demo2;

/**
 * 仅单线程可用
 * @author mac
 *
 */
public class SingleThreadedSingleton {
	private static SingleThreadedSingleton instance = null;
	
	//私有构造方法使其他类无法直接通过new创建该类的实例
	private SingleThreadedSingleton() {
		//什么也不做
	}
	
	public static SingleThreadedSingleton getInstance() {
		if(null==instance) {
			instance = new SingleThreadedSingleton();
		}
		return instance;
	}
	
	public void someService() {
		//省略其他代码
	}
}
